package cn.iocoder.yudao.module.wine.controller.app.advertisement;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.wine.controller.app.advertisement.vo.*;
import cn.iocoder.yudao.module.wine.dal.dataobject.advertisement.AdvertisementDO;
import cn.iocoder.yudao.module.wine.service.advertisement.AdvertisementService;

@Tag(name = "用户 APP - 广告信息")
@RestController
@RequestMapping("/wine/advertisement")
@Validated
public class AppAdvertisementController {

    @Resource
    private AdvertisementService advertisementService;

//    @PostMapping("/create")
//    @Operation(summary = "创建广告信息")
//    public CommonResult<Long> createAdvertisement(@Valid @RequestBody AppAdvertisementSaveReqVO createReqVO) {
//        return success(advertisementService.createAdvertisement(createReqVO));
//    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新广告信息")
//    public CommonResult<Boolean> updateAdvertisement(@Valid @RequestBody AppAdvertisementSaveReqVO updateReqVO) {
//        advertisementService.updateAdvertisement(updateReqVO);
//        return success(true);
//    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除广告信息")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteAdvertisement(@RequestParam("id") Long id) {
        advertisementService.deleteAdvertisement(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得广告信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppAdvertisementRespVO> getAdvertisement(@RequestParam("id") Long id) {
        AdvertisementDO advertisement = advertisementService.getAdvertisement(id);
        return success(BeanUtils.toBean(advertisement, AppAdvertisementRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得广告信息列表")
    public CommonResult<List<AppAdvertisementRespVO>> getAdvertisementPage(@Valid AppAdvertisementPageReqVO pageReqVO) {
        List<AdvertisementDO> list = advertisementService.getAdvertisementList(pageReqVO);
        return success(BeanUtils.toBean(list, AppAdvertisementRespVO.class));
    }

}
